// (c) Eric Korff de Gidts
// SPDX-License-Identifier: MIT
// stdafx.h
#pragma once

#define VC_EXTRALEAN
#include "targetver.h"

// COM/MFC related
#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS
#define _AFX_ALL_WARNINGS
#include <afxwin.h>
#include <afxext.h>
#include <afxdisp.h>
#include <afxdtctl.h>
#include <afxcmn.h>
#include <afxcontrolbars.h>
#include <afxdialogex.h>

#ifdef _UNICODE
#if defined _M_IX86
#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='x86' publicKeyToken='6595b64144ccf1df' language='*'\"")
#elif defined _M_X64
#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='amd64' publicKeyToken='6595b64144ccf1df' language='*'\"")
#else
#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")
#endif
#endif

// Define standard text conversions
#define __L(s) L#s
#define _L(s) __L(s)

// Resources related
#include "resource.h"

// Device setup related
#include <SetupAPI.h>
#pragma comment(lib, "SetupAPI.lib")

// Device configuration related
#include <cfgmgr32.h>
#pragma comment(lib, "Cfgmgr32.lib")

// Device properties related
#include <initguid.h>
#include <devpkey.h>
#include <devguid.h>
#include <winioctl.h>

// ETW related
#pragma warning(push)
#pragma warning(disable: 4005) // Duplicate definitions
#include <ntstatus.h>
#pragma warning(pop)
#include <evntprov.h>
#include <dpfilter.h>

// As defined in ntdef.h
#define NT_SUCCESS(Status) (((NTSTATUS)(Status)) >= 0)

// HID releated
#include <Hidsdi.h>
#include <hidclass.h>
#pragma comment(lib, "Hid.lib")

// USB related
#include <usbioctl.h>

// {D61CA365-5AF4-4486-998B-9DB4734C6CA3}add the XUSB class GUID as it is missing in the public interfaces 
DEFINE_GUID(GUID_DEVCLASS_XUSBCLASS, 0xD61CA365, 0x5AF4, 0x4486, 0x99, 0x8B, 0x9D, 0xB4, 0x73, 0x4C, 0x6C, 0xA3);

// {EC87F1E3-C13B-4100-B5F7-8B84D54260CB} add the XUSB interface class GUID as it is missing in the public interfaces 
DEFINE_GUID(GUID_DEVINTERFACE_XUSB, 0xEC87F1E3, 0xC13B, 0x4100, 0xB5, 0xF7, 0x8B, 0x84, 0xD5, 0x42, 0x60, 0xCB);

// {00000000-0000-0000-FFFF-FFFFFFFFFFFF} the system container id
DEFINE_GUID(GUID_CONTAINER_ID_SYSTEM, 0x00000000, 0x0000, 0x0000, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF);

// Extend guiddef.h with an operator that enables a GUID to be used in container classes
__inline bool operator<(REFGUID lhs, REFGUID rhs) noexcept
{
    return (::memcmp(&lhs, &rhs, sizeof(GUID)) < 0);
}

// Standard library related
#include <algorithm>
#include <cwctype>
#include <map>
#include <memory>
#include <filesystem>
#include <functional>
#include <iostream>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <tuple>
#include <utility>
#include <vector>

// Include the message file generated by the message compiler from the ETW manifest
#pragma warning(push)
#pragma warning(disable: 26451) // Warning(s) in code generated by the message compiler
#include "HidHideCLIETW.h"
#pragma warning(pop)
